//
//  ChengHuiTongUITests.m
//  ChengHuiTongUITests
//
//  Created by CHT-Technology on 2017/3/22.
//  Copyright © 2017年 张文权. All rights reserved.
//

#import <XCTest/XCTest.h>

@interface ChengHuiTongUITests : XCTestCase


@end

@implementation ChengHuiTongUITests

- (void)setUp {
    [super setUp];
    
    //每次测试启动会进入该方法,初始化相关配置
    self.continueAfterFailure = NO;
    // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
    [[[XCUIApplication alloc] init] launch];
    

}

- (void)tearDown {
    //每次测试结束会进入该方法
    [super tearDown];
}

- (void)testLogin_out{
    
    int index = 10;
    while (index > 0) {
        
        [self testLogin];
        [self testLogout];
        
        
        index --;
    }
}


- (void)testLogin{
    
    XCUIApplication *app =  [[XCUIApplication alloc]init];
    [app.tabBars.buttons[@"\u6211\u7684"] tap];
    [app.buttons[@"\u767b\u5f55"] tap];
    
    XCUIApplication *app2 = app;
    [app2.textFields[@"\u624b\u673a/\u90ae\u7bb1/\u7528\u6237\u540d"] tap];
    
    XCUIElement *moreKey = app2.keys[@"more"];
    [moreKey tap];
    [moreKey tap];
    [app2.secureTextFields[@"\u767b\u5f55\u5bc6\u7801"] typeText:@"12345678"];
    [app2.buttons[@"\u767b\u5f55"] tap];

    
}

- (void)testLogout{
    
    XCUIApplication *app = [[XCUIApplication alloc]init];
    [app.tabBars.buttons[@"\u6211\u7684"] tap];
    [[[[[[[[[[[[app childrenMatchingType:XCUIElementTypeWindow] elementBoundByIndex:0] childrenMatchingType:XCUIElementTypeOther].element childrenMatchingType:XCUIElementTypeOther].element childrenMatchingType:XCUIElementTypeOther].element childrenMatchingType:XCUIElementTypeOther].element childrenMatchingType:XCUIElementTypeOther].element childrenMatchingType:XCUIElementTypeOther].element childrenMatchingType:XCUIElementTypeOther].element childrenMatchingType:XCUIElementTypeButton] elementBoundByIndex:0] tap];
    
    [app.tables.staticTexts[@"\u9000\u51fa\u767b\u5f55"] tap];
    [app.alerts.buttons[@"\u786e\u5b9a"] tap];
    [app.buttons[@"\u8fd4\u56de"] tap];
    
}

@end
